# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=bindead
pkgver=4504.67019b97b
pkgrel=2
pkgdesc='A static analysis tool for binaries'
groups=('blackarch' 'blackarch-binary' 'blackarch-debugger'
        'blackarch-reversing')
arch=('any')
url='https://bitbucket.org/mihaila/bindead'
license=('GPL3')
depends=('bash' 'java-runtime')
makedepends=('git' 'java-environment' 'maven')
source=("git+https://bitbucket.org/mihaila/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  unset _JAVA_OPTIONS

  export MAVEN_OPTS="-Dmaven.repo.local=$srcdir -Xms256m -Xmx512m"

  ./build.sh
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"

  install -Dm 644 "$pkgname.jar" "$pkgdir/usr/share/$pkgname/$pkgname.jar"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
java -jar /usr/share/$pkgname/$pkgname.jar "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

